// Auth: WenYF
// Date: 2018/5/19
// 这个是管理所有页面加载

// 主容器的id：id_main_container
var sMainContainerId = "id_main_container"
// 显示高亮的导航栏
var preNegBarId = null

// tag:html文件的prefix并且是id的suffix
function loadMainHtml(levelPath, tag) {
    var filename = levelPath + "/" + tag + ".html"
    var nagBarId = "id_page_" + tag
    console.log("loadMainHtml=%s", filename)
    console.log("nagBarId=%s,preNegBarId=%s", nagBarId, preNegBarId)
    $.ajaxSetup ({ 
        cache: false //close AJAX cache 
    }); 
    var htmlObj = $.ajax({url:filename, async:false});
    $('.' + sMainContainerId).html(htmlObj.responseText);
    
    // 设置导航栏变色变化
    if (preNegBarId != null) {
        // 之前的还原
        document.getElementById(preNegBarId).setAttribute("class", "inactive-menu")
    }
    document.getElementById(nagBarId).setAttribute("class", "active-menu")
    preNegBarId = nagBarId
}

function showOperate() {
    loadMainHtml("l3", "operate");
}
function showBase() {
    loadMainHtml("l1", "base");
}
function showActivity() {
    loadMainHtml("l3", "activity");
}
function showStore() {
    loadMainHtml("l3", "store");
}

// 运营页面
function showSFIncome() {
    loadMainHtml("l2", "sf_income");
}

function showSFDay() {
    loadMainHtml("l2", "sf_day");
}

// 当进入到main.html后，将会先引导“基本信息页面”
// 第二种方法加载页面：jQuery $.ajax
$(document).ready(function(){
    console.log("开始加载基础信息页面")
    showBase()
});